<?php
require_once('pworks/mvc/ISystemDataHelper.iface.php');
require_once('pworks/mvc/SysDataType.class.php');


class DefaultSystemDataHelper implements ISystemDataHelper {

	public function get($name,$type) {

		$retVal = null;
		switch($type){
		case SysDataType::GET :{
			global $_GET;
			if(array_key_exists($name, $_GET)){
				$retVal = $_GET[$name];				
			}
			break;
		}
		case SysDataType::POST :{
			global $_POST;
			if(array_key_exists($name, $_POST)){
				$retVal = $_POST[$name];				
			}
			break;
		}
		case SysDataType::REQUEST :{
			global $_REQUEST;
			if(array_key_exists($name, $_REQUEST)){
				$retVal = $_REQUEST[$name];				
			}
			break;
		}
		case SysDataType::SERVER :{
			global $_SERVER;
			if(array_key_exists($name, $_SERVER)){
				$retVal = $_SERVER[$name];				
			}
			break;
		}
		case SysDataType::ENV :{
			if(getenv($name)){
				$retVal = getenv($name);			
			}
			break;
		}
		case SysDataType::COOKIE :{
			global $_COOKIE;
			if(array_key_exists($name, $_COOKIE)){
				$retVal = $_COOKIE[$name];				
			}
			break;
		}
		}
		return $retVal;
	}
}

